#include "IOParams.h"

IOParams::IOParams(int argc, char **argv){
//try{
  this->N = atoi(argv[1]); //40
  this->T1=atof(argv[2]);//4.0;
  this->T2=atof(argv[3]);//10.0;
  
  this->eps = atof(argv[4]); //1.0;
//  this->inpfilename(argv[5]);

  string strN(argv[1]);
  string strT1(argv[2]);
  string strT2(argv[3]);
  
  this->outfilename ="N_"+strN+"__T1_"+strT1+"__T2_"+strT2+".dat";
  this->outfilename2="N_"+strN+"__T1_"+strT1+"__T2_"+strT2+".trv";

  this->ttime = 0;
	    
//  this->sqrtT1=sqrt(T1);
//  this->sqrtT2=sqrt(T2);
	// TODO: Read InputParams.prm file
	ifstream paramFile;
	paramFile.open("InputParams.prm");
	
  string line;
	while( getline(paramFile,line) ){
	  stringstream linestream(line);
	 
	  string key;
	  getline(linestream,key,'=');

	  if (key=="total_time"){
	    getline(linestream,key,'=');
	    cout<<key<<endl;
	    this->total_time = atoi(key.c_str());
	    
	  }else if(key=="timeDim"){
		  getline(linestream,key,'=');
	    cout<<key<<endl;
	  	this->timeDim= atoi(key.c_str()); //40000;
	  	
	  }else if(key=="dt"){
	  	getline(linestream,key,'=');
	    cout<<key<<endl;
		  this->dt=atof(key.c_str());
	  }
	}
  paramFile.close();

  if (this->total_time > this->timeDim){
  	this->taux = this->total_time/this->timeDim;
  }else{
  	this->taux = 1;
  }

  this->dt2 = dt*dt;
  
  
  

//  }catch (exception& e){
//    cout << "Standard exception: " << e.what() << endl;
//  }
}

IOParams::~IOParams(){

}
